package com.iwe3.operation.handler;

import com.iwe3.operation.Enum.SystemEnum;
import com.iwe3.operation.common.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler
    public R handler(Exception e){
        if(e instanceof BussinessException){
            BussinessException be = (BussinessException) e;
            return R.fail(be.getCode());
        }
        return R.fail(SystemEnum.SYSTEM_BUSY);
    }
}
